package com.blog.controller;

import com.blog.dto.Result;
import com.blog.service.CategoryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/public/category")
public class CategoryController {
    @Resource
    private CategoryService categoryService;

    @GetMapping("/page/{categoryId}")
    public Result get_category_page_list(@PathVariable Integer categoryId,
                                         @RequestParam(defaultValue = "1") Integer pageNum,
                                         @RequestParam(defaultValue = "5") Integer pageSize) {
        return categoryService.get_category_page_list(categoryId,pageNum,pageSize);
    }

    @GetMapping("/categoryname/{categoryId}")
    public Result get_category_name(@PathVariable Integer categoryId) {
        return categoryService.get_category_name(categoryId);
    }

    @GetMapping("/list")
    public Result get_category() {
        return categoryService.get_category();
    }
}
